//
//  ChangeRoleViewController.m
//  penzer
//
//  Created by caiyc on 2018/10/4.
//  Copyright © 2018年 caiyc. All rights reserved.
//

#import "ChangeRoleViewController.h"
#import "AppDelegate.h"
#import "LoginViewController.h"
@interface ChangeRoleViewController ()
@property (weak, nonatomic) IBOutlet UIView *contentView;

@end

@implementation ChangeRoleViewController

- (void)viewDidLoad {
    [super viewDidLoad];
     [self setNavigation:1 andTitle:@"切换身份" andNaviColor:[UIColor whiteColor] andTitleColor:nil];
    if([XTool GetDefaultInfo:USER_INFO]){
    NSDictionary *dic = [XTool GetDefaultInfo:USER_INFO];
        NSString *acounts = [XTool setMobileToCharters:dic[@"mobile"]];
        self.user_Acount.text = [NSString stringWithFormat:@"用户 %@",acounts];
      
    }else{
        self.user_Acount.text = @"离线状态";
        [self.user_Btn setTitle:@"登录" forState:UIControlStateNormal];
    }
    if([XTool GetDefaultInfo:HOST_USER]){
        NSDictionary *dic = [XTool GetDefaultInfo:HOST_USER];
        NSString *acounts = [XTool setMobileToCharters:dic[@"mobile"]];
        self.host_Acount.text = [NSString stringWithFormat:@"主播 %@",acounts];
     //   self.host_Acount.text = dic[@"mobile"];
    }else{
        self.host_Acount.text = @"离线状态";
        [self.host_Btn setTitle:@"登录" forState:UIControlStateNormal];
    }
    if([XTool GetDefaultInfo:BUSSION_INFO]){
        NSDictionary *dic = [XTool GetDefaultInfo:BUSSION_INFO];
        NSString *acounts = [XTool setMobileToCharters:dic[@"mobile"]];
        self.bussion_Acount.text = [NSString stringWithFormat:@"商家 %@",acounts];
       // self.bussion_Acount.text = dic[@"mobile"];
    }else{
        self.bussion_Acount.text = @"离线状态";
        [self.bussion_Btn setTitle:@"登录" forState:UIControlStateNormal];
    }
    
    for(int i =0;i<3;i++){
        
    }
    // Do any additional setup after loading the view from its nib.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

- (IBAction)changeFunc:(UIButton *)sender {
    NSInteger index = sender.tag;
    AppDelegate *app =(AppDelegate*) [[UIApplication sharedApplication]delegate];
    if(sender.tag==0){
        if([XTool GetDefaultInfo:BUSSION_INFO]){
        [XTool SaveDefaultInfo:@"2" Key:Prole];
         [app changeRoot:2];
        }else{
            LoginViewController *vc = [[LoginViewController alloc]init];
            [self pushSecondVC:vc];
        }
//       [WToast showWithText:@"暂无端口开放"];
    }else if (sender.tag==1){
        if([XTool GetDefaultInfo:HOST_USER]){
        [XTool SaveDefaultInfo:@"1" Key:Prole];
        [app changeRoot:1];
        }else{
            LoginViewController *vc = [[LoginViewController alloc]init];
            [self pushSecondVC:vc];
        }
        
    }else{
        
        [XTool SaveDefaultInfo:@"0" Key:Prole];
        [app changeRoot:0];
    }
}
@end
